package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.CustLendPeriod;
import com.pgybook.db.entity.domain.CustLendPeriodEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface CustLendPeriodMapper {
    int countByExample(CustLendPeriodEx example);

    int deleteByExample(CustLendPeriodEx example);

    @Delete({
            "delete from custlendperiod",
            "where CUSTLENPERID = #{custlenperid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer custlenperid);

    @Insert({
            "insert into custlendperiod (CUSTID, TYPE, ",
            "AMOUNT, EXTENDDAYS, ",
            "STARTTIME, ENDTIME, ",
            "CRTTIME)",
            "values (#{custid,jdbcType=BIGINT}, #{type,jdbcType=INTEGER}, ",
            "#{amount,jdbcType=DECIMAL}, #{extenddays,jdbcType=INTEGER}, ",
            "#{starttime,jdbcType=TIMESTAMP}, #{endtime,jdbcType=TIMESTAMP}, ",
            "#{crttime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "custlenperid", before = false, resultType = Integer.class)
    int insert(CustLendPeriod record);

    int insertSelective(CustLendPeriod record);

    List<CustLendPeriod> selectByExample(CustLendPeriodEx example);

    @Select({
            "select",
            "CUSTLENPERID, CUSTID, TYPE, AMOUNT, EXTENDDAYS, STARTTIME, ENDTIME, CRTTIME",
            "from custlendperiod",
            "where CUSTLENPERID = #{custlenperid,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    CustLendPeriod selectByPrimaryKey(Integer custlenperid);

    int updateByExampleSelective(@Param("record") CustLendPeriod record, @Param("example") CustLendPeriodEx example);

    int updateByExample(@Param("record") CustLendPeriod record, @Param("example") CustLendPeriodEx example);

    int updateByPrimaryKeySelective(CustLendPeriod record);

    @Update({
            "update custlendperiod",
            "set CUSTID = #{custid,jdbcType=BIGINT},",
            "TYPE = #{type,jdbcType=INTEGER},",
            "AMOUNT = #{amount,jdbcType=DECIMAL},",
            "EXTENDDAYS = #{extenddays,jdbcType=INTEGER},",
            "STARTTIME = #{starttime,jdbcType=TIMESTAMP},",
            "ENDTIME = #{endtime,jdbcType=TIMESTAMP},",
            "CRTTIME = #{crttime,jdbcType=TIMESTAMP}",
            "where CUSTLENPERID = #{custlenperid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(CustLendPeriod record);
}
